First, with SparkIV, export your WEAPONS.ivaud from resident.rpf (find it in
pc\audio\Sfx). Open the WEAPONS.ivaud with GTA IV-aud and import all sound files
to here (match the names):

M4_SHOT1_L
M4_SHOT1_R
M4_SHOT2_A
M4_SHOT2_B
M4_SHOT2_C
M4_SHOT2_D

Save once done and import back to resident.rpf, Save and close.

If you are using the Silencer attachment, import all the sound files from the
"Silenced version" folder to here (match the names):

M4_SHOT1_L
M4_SHOT1_R
M4_SHOT2_A
M4_SHOT2_B
M4_SHOT2_C
M4_SHOT2_D

Now install this WeaponInfo to M4 line:

Non-silenced version (use this if you are using non-silencer attachment)

	<weapon type="M4">
		<data slot="RIFLE" firetype="INSTANT_HIT" damagetype="BULLET" group="RIFLE_ASSAULT" targetrange="30.0" weaponrange="500" clipsize="100" ammomax="400" timebetweenshots="100">
			<damage base="21" networkplayermod="2.5" networkpedmod="1.25"/>
			<physics force="39.6"/>
			<reload time="2066" fasttime="1166" crouchtime="2066"/>

			<aiming accuracy="0.7">
				<offset x="0.14" y="1.0" z="0.55"/>
				<crouchedoffset x="0.08" y="1.0" z="0.12"/>
				<reticule standing="0.6" ducked="0.5" scale="0.3"/>
			</aiming>

			<pickup regentime="480000" ammoonstreet="60"/>

			<controller>
				<rumble duration="168" intensity="0.38"/>
			</controller>

			<flags>
				<flag>GUN</flag>
				<flag>CAN_AIM</flag>
				<flag>2HANDED</flag>
				<flag>ANIM_RELOAD</flag>
				<flag>CAN_FREE_AIM</flag>
				<flag>ANIM_CROUCH_FIRE</flag>
			</flags>
		</data>

		<assets model="w_m4">
			<anim group="gun@ak47">
				<rates firerate="2" blindfirerate="2"/>
			</anim>
			<effects>
				<muzzle fx="muz_machine"/>
				<shell fx="weap_ejected_rifle"/>
			</effects>
		</assets>
	</weapon>

Silenced version (use this if you are using silencer attachment)

	<weapon type="M4">
		<data slot="RIFLE" firetype="INSTANT_HIT" damagetype="BULLET" group="RIFLE_ASSAULT" targetrange="30.0" weaponrange="520" clipsize="100" ammomax="400" timebetweenshots="100">
			<damage base="21" networkplayermod="2.5" networkpedmod="1.25"/>
			<physics force="39.6"/>
			<reload time="2066" fasttime="1166" crouchtime="2066"/>

			<aiming accuracy="0.72">
				<offset x="0.14" y="1.0" z="0.55"/>
				<crouchedoffset x="0.08" y="1.0" z="0.12"/>
				<reticule standing="0.6" ducked="0.5" scale="0.3"/>
			</aiming>

			<pickup regentime="480000" ammoonstreet="60"/>

			<controller>
				<rumble duration="168" intensity="0.38"/>
			</controller>

			<flags>
				<flag>GUN</flag>
				<flag>CAN_AIM</flag>
				<flag>2HANDED</flag>
				<flag>ANIM_RELOAD</flag>
				<flag>CAN_FREE_AIM</flag>
				<flag>ANIM_CROUCH_FIRE</flag>
				<flag>SILENCED</flag>
			</flags>
		</data>

		<assets model="w_m4">
			<anim group="gun@ak47">
				<rates firerate="2" blindfirerate="2"/>
			</anim>
			<effects>
				<muzzle fx="muz_machine"/>
				<shell fx="weap_ejected_rifle"/>
			</effects>
		</assets>
	</weapon>